package ch2Annotation;

import ch2.AccountService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AnnotationScan {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("/ch2/ch2-auto-scan-beans.xml");
        AccountService accountService = applicationContext.getBean("accountServiceImpl",AccountService.class);
        System.out.println("java annotaion; before transfer:");
        System.out.println("account 1 balance:"+accountService.getAccount(1).getBalance());
        System.out.println("account 2 balance:"+accountService.getAccount(2).getBalance());
        accountService.transferMoney(1,2,5.0);
        System.out.println("after transfer:");
        System.out.println("account 1 balance:"+accountService.getAccount(1).getBalance());
        System.out.println("account 2 balance:"+accountService.getAccount(2).getBalance());
    }

}
